from sqlalchemy import *
from migrate import *
from migrate.changeset import *

metadata = MetaData(migrate_engine)

nodetype_table = Table('nodetypes', metadata,
        Column('id', Integer, primary_key=True),
        Column('name', Unicode(100), nullable=False),
        Column('description', Text, nullable=True),
        Column('project_id', Integer, ForeignKey('projects.id'), \
               nullable=False),
        Column('shape', Unicode(25), nullable=True),
        Column('pen', Unicode(25), nullable=True),
        Column('brush', Unicode(25), nullable=True),
        Column('size', Integer, nullable=True),
        UniqueConstraint('name', 'project_id')
)

def upgrade():	
    # Upgrade operations go here. Don't create your own engine; use the engine
    # named 'migrate_engine' imported from migrate.    
    newcol = Column('visible_on_map', Boolean, default=True)
    create_column(newcol, nodetype_table)


def downgrade():
    # Operations to reverse the above upgrade go here.
    nodetype_table.drop()
    nodetype_table.create()